#include <stdlib.h> 
#include <string.h>
#include <unistd.h>
#include <time.h> 
#include <stdio.h> 


#include "data.grpc.pb.h"
#include "data.pb.h"

using namespace grpc;
using namespace std;

#define buffersize 4096
#define randof(num)  (int) ((float) (num) * random () / (RAND_MAX + 1.0))

int main(int argc, char* argv[])
{
    DeviceProperty response;
    response.set_version("0.0.1");
    printf("get %d attrs\n", response.attrinfo_size());
    PropertyInfo* info = response.add_attrinfo();
    info->set_attrname("VehicleInfo");
    VehicleInfo vi;
    vi.set_battery(89);
    info->set_attrvalue(vi.SerializeAsString());
    printf("get %d attrs\n", response.attrinfo_size());
    // while (1) {
    //    int zipcode = randof (10);
    //     printf("server send: %d\n", zipcode);
    //     sleep(1);
    // }
    return 0;
}